package com.huadi.firematerialident.dao;

import com.huadi.firematerialident.po.FireMaterialEvidenceInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class FireMaterialEvidenceInfoDaoImpl implements FireMaterialEvidenceInfoDao{

    @Autowired
    JdbcTemplate jdbcTemplate;

    public int addFireMaterialEvidenceInfo(FireMaterialEvidenceInfo firematerialevidenceinfo) {
        String sql="insert into FireMaterialEvidenceInfo values(?,?,?,?,'否',0,now())";
        return jdbcTemplate.update(sql,
                firematerialevidenceinfo.getMEID(),
                firematerialevidenceinfo.getFireInfoID(),
                firematerialevidenceinfo.getMEType(),
                firematerialevidenceinfo.getMoreInfo());
//                firematerialevidenceinfo.getArchivingStatus());

    }

    public int deleteFireMaterialEvidenceInfoByID(String meID) {
        String sql="update firematerialevidenceinfo set LogicalAddDel=0,LastModification=now() where MEID=?";
        return jdbcTemplate.update(sql,meID);
    }


    public int updateFireMaterialEvidenceInfo(FireMaterialEvidenceInfo firematerialevidenceinfo) {
        String sql="update firematerialevidenceinfo set MEID=?,FireInfoID=?,METype=?," +
                "MoreInfo=?,ArchivingStatus=?,LastModification=now() where MEID=?";
        return jdbcTemplate.update(sql,
                firematerialevidenceinfo.getMEID(),
                firematerialevidenceinfo.getFireInfoID(),
                firematerialevidenceinfo.getMEType(),
                firematerialevidenceinfo.getMoreInfo(),
                firematerialevidenceinfo.getArchivingStatus(),
                firematerialevidenceinfo.getMEID());
    }


    public List<Map<String,Object>> selectFireMaterialEvidenceInfoByID(String meID) {
        String sql = "select * from firematerialevidenceinfo where MEID = ?";
        return jdbcTemplate.queryForList(sql,meID);




    }



    public List<Map<String,Object>> getAllFireMaterialEvidenceInfo() {
        String sql="select * from firematerialevidenceinfo";
        return jdbcTemplate.queryForList(sql);
    }


}














